import { FormOptions } from "@/components/SmForm/src/types/types";
import { searchOptionsResolve } from "@/components/SmForm/src/utils";

export const useSearchForm = (handleQuery: any, queryParams: any) => {
  const searchFormOptions = ref<Array<FormOptions>>([
    {
      type: "input",
      label: "关键字",
      prop: "keywords",
      placeholder: "关键字",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "部门名称",
      prop: "name",
      placeholder: "部门名称",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },

    {
      type: "date-picker",
      placeholder: "创建时间",
      prop: "createTime",
      label: "创建时间",
      attrs: {
        clearable: true,
        type: "daterange",
        "range-separator": "~",
        editable: false,
        "value-format": "YYYY-MM-DD",
        "start-placeholder": "开始日期",
        "end-placeholder": "结束日期",
      },
    },
  ]);

  searchOptionsResolve(searchFormOptions, handleQuery);

  const getSearchFormData = () => {
    return queryParams;
  };
  return {
    searchFormOptions,
    getSearchFormData,
  };
};
